home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Direct Blitting in C++ / Blitting.sit / Blitting ƒ / StGWorldSetter.h < prev    next >
Text File  |  1995-04-23  |  1KB  |  53 lines

  1. // StGWorldSetter.h, a stack based GWorld setter and restorer
  2. //
  3. // Copyright ⌐ 1995, Macneil Shonle. All rights reserved.
  4.  
  5. #ifndef __STGWORLDSETTER__
  6. #define __STGWORLDSETTER__
  7.  
  8. #ifndef __QDOFFSCREEN__
  9. #include <QDOffscreen.h>
  10. #endif
  11.  
  12. #ifndef __CDIRECTBLIT__
  13. #include <CDirectBlit.h>
  14. #endif
  15.  
  16. class StGWorldSetter {
  17. public:
  18.     StGWorldSetter( CGrafPtr port, GDHandle gdh = nil );
  19.     StGWorldSetter( WindowRef port );
  20.     StGWorldSetter( GWorldPtr port );
  21.     StGWorldSetter( CDirectBlit &port );
  22.     ~StGWorldSetter();
  23.     
  24. private:
  25.     CGrafPtr mOrigPort;
  26.     GDHandle mOrigDev;
  27. };
  28.  
  29. inline StGWorldSetter::StGWorldSetter( CGrafPtr port, GDHandle gdh )
  30. {    ::GetGWorld( &mOrigPort, &mOrigDev );
  31.     ::SetGWorld( port, gdh );
  32. }
  33.  
  34. inline StGWorldSetter::StGWorldSetter( WindowRef port )
  35. {    ::GetGWorld( &mOrigPort, &mOrigDev );
  36.     ::SetGWorld( CGrafPtr(port), GetMainDevice() );
  37. }
  38.  
  39. inline StGWorldSetter::StGWorldSetter( GWorldPtr port )
  40. {    ::GetGWorld( &mOrigPort, &mOrigDev );
  41.     ::SetGWorld( CGrafPtr(port), nil );
  42. }
  43.  
  44. inline StGWorldSetter::StGWorldSetter( CDirectBlit &port )
  45. {    ::GetGWorld( &mOrigPort, &mOrigDev );
  46.     ::SetGWorld( port.GetMacPort(), port.GetMacDevice() );
  47. }
  48.  
  49. inline StGWorldSetter::~StGWorldSetter()
  50. {    ::SetGWorld( mOrigPort, mOrigDev );
  51. }
  52.  
  53. #endif